<?
$f=file("/etc/zaptel.conf");
$tmp=0;
$b_channel="".($dcase*31-30)."-".(($dcase*31-30)+14).",".(($dcase*31-30)+16)."-".($dcase*31);
$d_channel=(($dcase*31-30)+15);
$t=array();
foreach($f as $i){
    if(preg_match("!^(#|//)!", $i))continue;
    if(preg_match("!^span=$dcase!", $i))$tmp=1;
    if(preg_match("!^span=$dcase,(0|1),(0|1|2|3|4|5|6|7),(cas|ccs),(ami|hdb3),(crc4)$!", $i))
	preg_match("!^span=$dcase,(0|1),(0|1|2|3|4|5|6|7),(cas|ccs),(ami|hdb3),(crc4)$!", $i, $t);
    if(preg_match("!^span=$dcase,(0|1),(0|1|2|3|4|5|6|7),(cas|ccs),(ami|hdb3)$!", $i))
	preg_match("!^span=$dcase,(0|1),(0|1|2|3|4|5|6|7),(cas|ccs),(ami|hdb3)$!", $i, $t);
}
if($tmp==1){
    $active="<select id=\"on_off\" name=\"on_off\" onchange=\"disable_e1(this.value, ".$dcase.")\" class=\"select\">"
    	    ."<option selected value=\"1\">Да</option>"
    	    ."<option value=\"0\">Нет</option>"
    	    ."</select>";
    $type_arr=array("Ведомый", "Ведущий");
    $type="<select id=\"type\" name=\"type\"  class=\"select\">";
    for($i=0;$i<=1;$i++){
	if($t[1]==$i)$type.="<option selected value=\"".$i."\">".$type_arr[$i]."</option>";
        else $type.="<option value=\"".$i."\">".$type_arr[$i]."</option>";
    }
    $type.="</select>";
    $lbo_arr=array("0-133 feet (DSX-1)","133-266 feet (DSX-1)","266-399 feet (DSX-1)","399-533 feet (DSX-1)","533-655 feet (DSX-1)","-7.5db (CSU)","-15db (CSU)","-22.5db (CSU)");
    $lbo="<select id=\"lbo\" name=\"lbo\"  class=\"select\">";
    for($i=0;$i<=7;$i++){
	if($t[2]==$i)$lbo.="<option selected value=\"".$i."\">".$lbo_arr[$i]."</option>";
        else $lbo.="<option value=\"".$i."\">".$lbo_arr[$i]."</option>";
    }
    $lbo.="</select>";
    $ftype_arr=array("cas", "ccs");
    $ftype="<select id=\"ftype\" name=\"ftype\"  class=\"select\">";
    foreach($ftype_arr as $i){
	if($t[3]==$i)$ftype.="<option selected value=\"".$i."\">".$i."</option>";
        else $ftype.="<option value=\"".$i."\">".$i."</option>";
    }
    $ftype.="</select>";
    $ktype_arr=array("ami", "hdb3");
    $ktype="<select id=\"ktype\" name=\"ktype\"  class=\"select\">";
    foreach($ktype_arr as $i){
	if($t[4]==$i)$ktype.="<option selected value=\"".$i."\">".$i."</option>";
        else $ktype.="<option value=\"".$i."\">".$i."</option>";
    }
    $ktype.="</select>";
    $stype_arr=array("crc4", "no");
    $stype="<select id=\"stype\" name=\"stype\"  class=\"select\">";
    if(sizeof($t)==6){
	foreach($stype_arr as $i){
    	    if($t[5]==$i)$stype.="<option selected value=\"".$i."\">".$i."</option>";
    	    else $stype.="<option value=\"".$i."\">".$i."</option>";
	}
    }
    else{
	$stype.="<option value=\"crc4\">crc4</option><option selected value=\"no\">no</option>";
    }
    $stype.="</select>";

    $table=xparse("tpl/dcase.html");
}
else{
    $active="<select id=\"on_off\" name=\"on_off\" onchange=\"disable_e1(this.value, ".$dcase.")\" class=\"select\">"
    	    ."<option value=\"1\">Да</option>"
    	    ."<option selected value=\"0\">Нет</option>"
    	    ."</select>";
    $table=xparse("tpl/dcase_.html");
}
$table.="<script>disable_e1(".$tmp.", ".$dcase.")</script>";
?>